<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>待审批列表</title>
    <link href="../css/font.css" type="text/css" rel="stylesheet">
    <link href="../css/style.css" type="text/css" rel="stylesheet">
    <!--block[hdcss]-->

    <!--block[hdcss]end-->
</head>
<body>
<!--block[content]-->
<section class="wrap">
    <div class="page">
        <!--<header class="hd">头部 </header>-->
        <ul class="m-list">

        </ul>
        <!--<div class="u-btn-area">-->
        <!--<a class="u-btn u-btn-error" href="javascript:void(0)">-->
        <!--删&nbsp;&nbsp;除-->
        <!--</a>-->
        <!--</div>-->

    </div>
</section>
<footer class="ft">底部 </footer>
<!--block[content]end-->
<script type="text/tmpl" id="jTmpl_user_list">
    {{#data}}
    <li order-id="{{order_id}}">
        <div class="thumb">
            <span class="checkbox fa fa-check-circle-o"></span>
        </div>

            <div class="cont">
                <div>{{subject}}</div>
                <div><span  class="state {{status}}">{{txt}}</span><span class="date">{{start_at}}</span></div>
            </div>

        <div class="flag">
            <span class="fa fa-angle-right"></span>
        </div>
         <a href="./checkingInfo.html?order_id={{order_id}}" class="link"> </a>
    </li>
    {{/data}}
</script>
<script src="../js/lib/zepto.min.js" type="text/javascript"></script>
<script src="../js/plugin/juicer-min.js" type="text/javascript"></script>
<script src="../js/lib/mustache.js" type="text/javascript"></script>
<script type="text/javascript">
    var getDate = function(url,callback){
        var type =  type || 'get';
        $.ajax({
            url:url,// 跳转到 action
            type:'get',
            dataType:'jsonp',
            success:function(data) {
                callback && callback(data);
            }
        });
    };

    let tpl = $('#jTmpl_user_list').html();

    const baseUrl = 'http://lres.gzhc365.com/gxyj/api/';
    let url = baseUrl + 'order/check_list?callback=';

    function movieType(type) {
        var t = '';
        var s = '';
        switch (type) {
            case 0:
                t = 'p-status-fail';
                s = '未审批';
                break;
            case 1:
                t = 'p-status-ing';
                s = '通过';
                break;
            case 2:
                t = 'p-status-doing';
                s = '未通过';
                break;
            default:
                t = '';
        }

        return {style:t,txt:s};
    }

    getDate(url,function(json){
        console.log(json)


        if(json && json.code == 200){
            let data = json.data;
            $.each(data.data,function(i){
                data.data[i].status = movieType(data.data[i].check_status).style
                data.data[i].txt = movieType(data.data[i].check_status).txt
            });

            if(data.data.length){
                let element = Mustache.render(tpl, json);
                $('.m-list').html(element);
            }else{
                $('.page').html('<p style="text-align:center;margin-top:20px">您好，数据为空</p>');
            }


        }else if(json.code == 1003){
            let l = window.location.href;
            window.location = 'http://lres.gzhc365.com/gxyj/api/auth/wx_authorize?return_url='+l
        }
    })

</script>
<!--block[endscript]end-->
</body>
</html>